/**
 * <pre>
 * @(#)Enum.java 1.00 2009-8-10
 * 
 * Copyright (c) 1998, 2009 Regular Individual. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * Contributor(s):
 *     Haixu Huang
 * </pre>
 **/
package cn.sh.huang.chart.ext.enumtype;

/**
 * <pre>
 * Enum ...
 * 
 * @version 1.0
 * </pre>
 */
abstract public class Enum implements Comparable
{ // Collection.retainAll needs object to implement Comparable
    private final String value;

    public Enum(String value)
    {
        this.value = value;
    }

    public boolean equals(Object o)
    {
        return compareTo(o) == 0;
    }

    public String toString()
    {
        return value;
    }

    public int compareTo(Object o)
    {
        if (o != null) {
            if (this.getClass().equals(o.getClass())) {
                Enum e = (Enum) o;
                return value == null ? (e.value == null ? 0 : -1) : value.compareTo(e.value);
            }
        }
        return -1;
    }
}
